package com.nbsaas.boot.front.example;

import com.nbsaas.boot.example.api.apis.ExampleCatalogApi;
import com.nbsaas.boot.example.api.domain.request.ExampleCatalogRequest;
import com.nbsaas.boot.example.api.domain.request.ExampleCatalogSearch;
import com.nbsaas.boot.example.api.domain.response.ExampleCatalogResponse;
import com.nbsaas.boot.example.api.domain.simple.ExampleCatalogSimple;
import com.nbsaas.boot.rest.annotations.ViewOperator;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 案例分类控制器
 */
@RestController
@RequestMapping("/front/exampleCatalog")
public class ExampleCatalogAction {


    @Resource
    private ExampleCatalogApi exampleCatalogApi;

    /**
     * 搜索数据
     *
     * @param request
     * @return
     */
    @PostMapping("/search")
    public PageResponse<ExampleCatalogSimple> search(@RequestBody ExampleCatalogSearch request) {
        return exampleCatalogApi.search(request);
    }

    /**
     * 列表数据
     *
     * @param request
     * @return
     */
    @PostMapping("/list")
    public ListResponse<ExampleCatalogSimple> list(@RequestBody ExampleCatalogSearch request) {
        return exampleCatalogApi.list(request);
    }


    /**
     * 查看数据
     *
     * @param request
     * @return
     */
    @PostMapping("/view")
    public ResponseObject<ExampleCatalogResponse> view(@RequestBody @Validated(ViewOperator.class) ExampleCatalogRequest request) {
        return exampleCatalogApi.view(request);
    }
}